package com.yinhe.music.yhmusic.album.info;

import com.yinhe.music.yhmusic.base.BaseModel;
import com.yinhe.music.yhmusic.collect.CollectPresenter;
import com.yinhe.music.yhmusic.network.response.ResponseTransformer;

public class AlbumPresenter extends CollectPresenter<BaseModel, AlbumInfoContract.IAlbumInfoView> implements AlbumInfoContract.IAlbumInfoPresenter {

    @Override
    public void getAlbumInfo(int id) {
        if (getView() == null) {
            return;
        }

        addSubscription(mModel.getAlbumInfo(id)
            .compose(ResponseTransformer.handleResult())
            .compose(schedulerProvider.applySchedulers())
            .subscribe(albumInfo -> getView().setAlbumInfoUI(albumInfo),
                throwable -> getView().showMessage(throwable)
            )
        );
    }
}
